import { getRoleInfoApi } from '../api/auth'
import { getMenuInfoApi } from '../api/menus'
import { transListToTreeData } from '../utils/tree'
export const useReplayData = () => {
  const replayData = async (id, obj) => {
    let res = await getRoleInfoApi(id)
    const menuList = transListToTreeData(res.data.menuList, 0)
    const str = res.data.menus
    const arr = str.split(',')
    const menus = arr.map(item => item * 1)
    const roleObj = {
      description: res.data.description,
      menus: menus,
      name: res.data.name,
      status: res.data.status,
      id: res.data.id
    }
    Object.assign(obj, roleObj)
  }
  return { replayData }
}
export const useMenuReply = () => {
  const replayData = async (obj, id) => {
    let res = await getMenuInfoApi(id)
    Object.assign(obj, res.data)
    console.log(obj);
  }
  return { replayData }
}